/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Niels Leguit <niels.leguit at hva.nl>
 * @version $Id: DateHelper.java,v 1.0 2012/05/01 $
 */
public class DateHelper {

    public static final String DateFormat = "dd/MM/yyyy";     // bv 2012-04-30 johan: aangepast naar 30/04/2012
    public static final String TimeFormat = "H:mm";                // bv 22:35
    public static final String DateTimeFormat = "dd/MM/yyyy H:mm"; // bv 2012-04-30 22:35

    public static Date toDate(String string) throws ParseException {
        DateFormat formatter = new SimpleDateFormat(DateFormat);
        return formatter.parse(string);
    }

    public static String toStringDate(Date date) {
        DateFormat formatter = new SimpleDateFormat(DateFormat);
        String string = formatter.format(new Date(date.getTime()));
        return string;
    }

    public static Date toTime(String string) throws ParseException {
        DateFormat formatter = new SimpleDateFormat(TimeFormat);
        return formatter.parse(string);
    }

    public static String toStringTime(Date date) {
        DateFormat formatter = new SimpleDateFormat(TimeFormat);
        String string = formatter.format(new Date(date.getTime()));
        return string;
    }

    public static Date toDateWithTime(String string) throws ParseException {
        DateFormat formatter = new SimpleDateFormat(DateTimeFormat);
        return formatter.parse(string);
    }

    public static String toStringWithTime(Date date) {
        DateFormat formatter = new SimpleDateFormat(DateTimeFormat);
        String string = formatter.format(new Date(date.getTime()));
        return string;
    }

//    public static Date getDateTime() {
//        Date date = new Date(System.currentTimeMillis());
//        return date;
//    }
}
